package com.zlm.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 企业性质枚举类
 * @Author: duyufu
 * @Date: 2019/4/24 13:16
 */
public enum CompanyNatureEnum {
	COMPANY_NATURE_NO_LIMIT(0,"不限"),
	COMPANY_NATURE_COUNTRY(1, "国有企业"),
	COMPANY_NATURE_TAIWAN(2, "台资企业"),
	COMPANY_NATURE_FOREIGN_CAPITAL(3, "外资企业"),
	COMPANY_NATURE_JOINT_VENTURE(4, "合资企业"),
	COMPANY_NATURE_PRIVATE(5, "私营企业"),
	COMPANY_NATURE_PEOPLE(6, "民营企业"),
	COMPANY_NATURE_SHARES(7, "股份制企业"),
	COMPANY_NATURE_INSTITUION(8, "事业单位"),
	COMPANY_NATURE_OTHER(9, "其他");

	private Integer code;
	private String name;

	private CompanyNatureEnum(Integer code, String name) {
		this.code = code;
		this.name = name;
	}

	public static List getCompanyNature() {
		List list = new ArrayList();
		Map<String, Object> map;
		for (CompanyNatureEnum panyEnum : CompanyNatureEnum.values()) {
			map = new HashMap<String, Object>();
			map.put("code", panyEnum.getCode());
			map.put("name", panyEnum.getName());
			list.add(map);
		}
		return list;
	}

	public static String getNameByCode(Integer code) {
		for (CompanyNatureEnum natureEnum : CompanyNatureEnum.values()) {
			if(natureEnum.getCode().equals(code)){
				return natureEnum.getName();
			}
		}
		return null;
	}

	public static String getCompanyNatureJsonString() {
		StringBuilder builder = new StringBuilder("{");
		for (CompanyNatureEnum panyEnum : CompanyNatureEnum.values()) {
			builder.append("\"" + panyEnum.getCode() + "\":\"" + panyEnum.getName() + "\",");
		}
		String json = builder.substring(0, builder.length() - 1) + "}";
		return json;
	}

	@Override
    public String toString() {
		return "[code=" + code + ", name=" + name + "]";
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
